package com.atguigu.crowd.mvc.config;

import crowd.entity.Admin;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.List;


public class SecurityAdmin extends User {

    private Admin originalAdmin;

    public SecurityAdmin(Admin originalAdmin, List<GrantedAuthority> authorities){

        // 调用父类的构造器
        super(originalAdmin.getUserName(), originalAdmin.getUserPswd(), authorities);

        // 将Admin对象放入对象
        this.originalAdmin = originalAdmin;

        // 为了保证安全性，擦除放入originalAdmin的对象的密码
        this.originalAdmin.setUserPswd(null);

    }

    public Admin getOriginalAdmin() {
        return originalAdmin;
    }
}
